package com.diankangwo.scheduling;

import com.diankangwo.factory.service.*;
import com.diankangwo.util.AccountUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/** 定时任务配置类
 * Created by wuye on 2017/9/15.
 */
@Configuration
@EnableScheduling // 启用定时任务
public class SchedulingConfig {
    @Autowired
    private TdFactoryService tdFactoryService;
    @Autowired
    private TdOrderService tdOrderService;
    @Autowired
    private TdAccountService tdAccountService;
    @Autowired
    private TdShoppingcartServices tdShoppingcartServices;
    @Autowired
    private TdOrderShoppingcartServices tdOrderShoppingcartServices;
    @Autowired
    private TdCommodityService tdCommodityService;
    @Autowired
    private TdUserInfoService tdUserInfoService;

    @Scheduled(cron = "0 0 0 1/20 * ? ") // 每20秒执行一次
    public void scheduler() {
        System.out.println("执行定时任务");
        //获取数据中状态为未结算，同时从订单开始时间当定时器执行时间间隔为10天
        AccountUtil a = new AccountUtil();
        a.setUserInfo(tdFactoryService,tdOrderService,tdAccountService,tdShoppingcartServices,tdOrderShoppingcartServices,tdCommodityService,tdUserInfoService);
        a.accountFactory();
    }
}
